//
// MT6816CT_STD_H
// Created by Xiaoyun on 23.3.25.
//

#ifndef FOC_MT6816CT_STD_H
#define FOC_MT6816CT_STD_H

#include <stdint.h>
#include <stdbool.h>

#ifndef __weak
#define __weak   __attribute__((weak))
#endif

#define MT6816_QueueSize 5 // less than 256
#define MT6816_ANGLE_MAX (16384)
#define ENCODER_ANGLE_OFFSET (15725)

typedef struct {
  uint16_t angle: 14;
  uint16_t no_mag: 1;
  uint16_t over_speed: 1;
} MT6816_Data_t;

/*----------------User Functions----------------*/

void MT6816_SPI_Read2Queue();

bool MT6816_Get_Data(MT6816_Data_t *data, uint8_t seq);

uint8_t MT6816_Get_Queue_Size();

bool MT6816_Get_Queue_Head(MT6816_Data_t *data);

/*----------------Weak Functions(User to implement)----------------*/

void MT6816_SPI_TransmitReceive(uint8_t *pTxData, uint8_t *pRxData, uint8_t size);

#endif //FOC_MT6816CT_STD_H
